/**
 * Created by lighter on 2014/12/20.
 */
package Hxw3DEngine.asset.parsers.bson.vo {
import flash.utils.ByteArray;
import flash.utils.Endian;

public class MeshVO {
    public var name:String;
    public var flags:uint;
    public var material:uint;
    public var streams:Vector.<Stream>;
    public var joints:ByteArray;
    public var trangle_type:uint;
    public var vertices:uint;
    public var bones_per_vertex:uint;
    public var indices:uint;
    public var bound:ByteArray;

    public function MeshVO(obj:Object) {
        name = obj.name;
        flags = obj.flags;
        material = obj.material;
        streams = new Vector.<Stream>(obj.streams.length);
        for (var i:uint = 0; i < obj.streams.length; i++) {
			
			// 暂且如此
			if (obj.streams[i] is Stream) {
				streams[i] = obj.streams[i];
			}else{
				streams[i] = new Stream(obj.streams[i]);
			}
        }
        if(obj.hasOwnProperty("joints")){
            joints = obj.joints.data;
        }
        trangle_type = obj.trangle_type;
        vertices = obj.vertices;
        bones_per_vertex = obj.bones_per_vertex;
        indices = obj.indices;
		if(obj.hasOwnProperty("bound")){
			bound = obj.bound.data;
		}
    }

    public static function create(obj:Object):Object{
        return new MeshVO(obj);
    }
	public function getComponents():uint {
        var components:uint = 0;
		for (var i:uint = 0; i < streams.length; i++) {
			components |= streams[i].components;
        }
		return components;
	}
}
}
